<template>
	<view class="page">
		<view class="list">
			<view class="item" v-for="(item,index) in list">
				<view class="info">
					<image :src="item.thumb" class="logo"></image>
					<view class="content">
						<view class="tit">{{item.title}}</view>
						<view class="address">{{item.address}}</view>
					</view>
				</view>
				<view class="operation">
					<view class="btn" @click="del(item.id,index)">删除</view>
					<view class="btn" @click="$navTo('./supermarketZtdSet?id='+item.id)">编辑</view>
				</view>
			</view>
		</view>
		<view class="totalBtn" @click="$navTo('./supermarketZtdSet')">添加自提点</view>
		<view class="empty_loading">
			<image v-if="isloading" src="/static/business/loading.gif" ></image>
			<text v-if="isempty">到底了~</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				page: 0,
				isloading: false,
				isempty: false,
			};
		},
		onLoad() {
			this.getList();
		},
		onReachBottom() {
			this.getList();
		},
		methods: {
			getList(){
				this.page++;
				this.isloading = true;
				this.isempty = false;
				this.$axios('market/pickuplist','POST','supplier',{
					page: this.page,
				}).then(res=>{
					this.isloading = false;
					if(res.data.code == 200){
						this.list = [...this.list,...res.data.data.list];
						this.isempty = res.data.data.list.length <= 0;
					}
				})
			},
			del(id,idx){
				uni.showModal({
					title: '提示',
					content: '确定删除？',
					success: res=>{
						if (res.confirm) {
							this.$axios('market/pickupDel','POST','supplier',{
								id
							}).then(res=>{
								if(res.data.code == 200){
									this.$api.msg(res.data.data);
									this.list.splice(idx,1);
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			}
		}
	}
</script>

<style lang="scss">
page{
	background: #f8f8fe;
	padding-bottom: 120rpx;
}
.page{
	padding: 20rpx;
}
.list{
	.item{
		background: #fff;
		border-radius: 12rpx;
		padding: 20rpx;
		margin-bottom: 20rpx;
		.info{
			display: flex;
			align-items: center;
			.logo{
				width: 130rpx;
				height: 130rpx;
				border-radius: 12rpx;
			}
			.content{
				flex: 1;
				padding-left: 20rpx;
				.tit{
					font-weight: 600;
					margin-bottom: 10rpx;
				}
				.address{
					color: #999;
					font-size: 22rpx;
				}
			}
		}
		.operation{
			display: flex;
			justify-content: flex-end;
			.btn{
				margin-left: 20rpx;
				width: 140rpx;
				height: 58rpx;
				border-radius: 12rpx;
				border: 2rpx solid #DEDEDE;
				line-height: 58rpx;
				text-align: center;
				font-size: 24rpx;
				color: #333333;
			}
		}
	}
}
</style>
